#include <stdio.h>

struct stuInfo
{
    char stuId[100],name[100];
    int score_1, score_2, score_3,totalScore;
};

void input(struct stuInfo * stu, int num);
void handle(struct stuInfo * stu, int num);
int main(int argc, char *argv[]) {
    int num;
    scanf("%d", &num);
    
    struct stuInfo stu[100];
    input(stu, num);
    handle(stu, num);
    return 0;
}

void input(struct stuInfo *stu, int num){
    for (int i = 0; i < num; i++)
    {
        scanf("%s %s %d %d %d",stu[i].stuId,stu[i].name,&stu[i].score_1,&stu[i].score_2,&stu[i].score_3);
    }
}

void handle(struct stuInfo *stu,int num){
    int sum1=0, sum2=0, sum3=0;
    int avg1=0, avg2=0, avg3=0;
    for (int i = 0; i < num; i++)
    {
        sum1 += stu[i].score_1;
        sum2 += stu[i].score_2;
        sum3 += stu[i].score_3;
    }

    for (size_t i = 0; i < num; i++)
    {
        stu[i].totalScore = stu[i].score_1 + stu[i].score_2 + stu[i].score_3;
    }
    
    
    avg1 = sum1 / num;
    avg2 = sum2 / num;
    avg3 = sum3 / num;

    int max=0,maxIndex=0;
    for (size_t i = 0; i < num; i++)
    {
        if(stu[i].totalScore>max){
            max = stu[i].totalScore;
            maxIndex = i;
        }
    }
    
    printf("%d %d %d\n", avg1, avg2,avg3);
    printf("%s %s %d %d %d",stu[maxIndex].stuId,stu[maxIndex].name,stu[maxIndex].score_1,stu[maxIndex].score_2,stu[maxIndex].score_3);

}
